﻿using System;
using System.IO.IsolatedStorage;

namespace MVVMS.Helpers
{

    public static class AppSettings
    {
        public static T LoadSetting<T>(string key)
        {
            T ObjToLoad = default(T);

            if (IsolatedStorageSettings.ApplicationSettings.Contains(key))
            {
                ObjToLoad = (T)IsolatedStorageSettings.ApplicationSettings[key];
            }

            return ObjToLoad;
        }

        public static T LoadSetting<T>(string key, T defaultValue)
        {
            T ObjToLoad = defaultValue;

            if (IsolatedStorageSettings.ApplicationSettings.Contains(key))
            {
                ObjToLoad = (T)IsolatedStorageSettings.ApplicationSettings[key];
            }

            return ObjToLoad;
        }
        public static void SaveSetting<T>(string key, T value)
        {
            IsolatedStorageSettings.ApplicationSettings[key] = value;
        }
    }
}
